﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using Webdiver;

namespace AnyOffice.general.report.manage
{
    public partial class index1 : ModulePage
    {
        public void ChangePage(object src, PageChangedEventArgs e)
        {
            this.AspNetPager1.CurrentPageIndex = e.NewPageIndex;
            this.BindData();
        }
        public string GetUserNames(string userIds)
        {
            return StringHelper.GetUserNames(base.Conn, userIds);
        }
        public bool IsExists(int reportId)
        {
            return new ReportCommentDao().IsExists(base.Conn, reportId);
        }
        private void BindData()
        {
            DataTable table = new ReportDao().SelectPaged(base.Conn, this.AspNetPager1.PageSize, this.AspNetPager1.CurrentPageIndex, false, base.User.Identity.Name);
            this.ViewState["CurrentRowNums"] = table.Rows.Count;
            this.ViewState["CurrentPage"] = this.AspNetPager1.CurrentPageIndex.ToString();
            this.rptReport.DataSource = table;
            this.rptReport.DataBind();
            this.litNavCount.Text = "<span class=\"small1\">共&nbsp;<span class=\"big4\">" + this.AspNetPager1.RecordCount.ToString() + "</span>&nbsp;条";
            this.litNavPager.Text = "<span class=\"small1\">当前为第" + this.AspNetPager1.CurrentPageIndex.ToString() + "页，共" + this.AspNetPager1.PageCount.ToString() + "页，每页最多" + this.AspNetPager1.PageSize.ToString() + "条</span>";
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.AspNetPager1.PageSize = new ConfigManager().PageSize;
                DataTable table = new ReportDao().SelectPaged(base.Conn, this.AspNetPager1.PageSize, this.AspNetPager1.CurrentPageIndex, true, base.User.Identity.Name);
                if (int.Parse(table.Rows[0][0].ToString()) == 0)
                {
                    this.litNavCount.Visible = false;
                    this.litNavPager.Visible = false;
                    this.pnlMain.Visible = false;
                    this.litMessage.Text = base.ShowMessage("无已发布的工作汇报");
                }
                else
                {
                    this.AspNetPager1.RecordCount = int.Parse(table.Rows[0][0].ToString());
                    this.BindData();
                }
            }
        }

        /// <summary>
        /// 根据类型编号，得到类型名称
        /// </summary>
        /// <param name="typeid"></param>
        /// <returns></returns>
        public string getTypeNameByTypeID(string typeid)
        { 
            string returnstr=string.Empty;

            if (typeid == "1")
            {
                returnstr = "项目汇报";
            
            }
            else if (typeid == "2")
            {
                returnstr = "事务汇报";
            
            }
            //else if (typeid == "3")
            //{
            //    returnstr = "年汇报";

            //}

            return returnstr; 
        
        }

        /// <summary>
        /// 根据类型编号，得到类型名称
        /// </summary>
        /// <param name="typeid"></param>
        /// <returns></returns>
        public string getJsNameByTypeID(string typeid)
        {
            string returnstr = string.Empty;

            if (typeid == "1")
            {
                returnstr = "open_month";

            }
            else if (typeid == "2")
            {
                returnstr = "open_week";

            }
            else if (typeid == "3")
            {
                returnstr = "open_year";

            }

            return returnstr;

        }



 

    }
}
